<template>
  <!--  个性特征      -->
  <view class="personality-attributes">
    <view class="title-img-box">
      <image class="title-img" :src="partTextImgUrl" />
    </view>
    <view class="content-wrapper">
      <view class="content">
        <view class="title-box">
          <view class="black-line"> </view>
          <text class="title-en">{{ dataItem.title }}</text>
        </view>
        <view class="title-ch">{{ dataItem.subTitle }}</view>
        <view class="avatar-box">
          <image class="avatar" :src="dataItem.pic" />
        </view>
        <view class="progress-container">
          <Progress
            v-for="(item, index) in dataItem.attribute"
            :key="index"
            :numColor="itemList[index].numColor"
            :roundColor="itemList[index].roundColor"
            :barColor="itemList[index].barColor"
            :leftText="itemList[index].leftText"
            :rightText="itemList[index].rightText"
            :itemData="item"
          ></Progress>
        </view>
        <view class="desc">
          {{ dataItem.desc }}
        </view>
      </view>
    </view>
  </view>
</template>

<script>
import Progress from './Progress';
export default {
  components: { Progress },
  props: {
    dataItem: {
      type: Object,
      default: () => {}
    }
  },
  data() {
    return {
      partTextImgUrl:
        this.$imgBaseSelf + 'career/careerAssessNewImg/01_title.png',
      avatar: this.$imgBaseSelf + 'career/careerAssessNewImg/01_avatar.png',
      itemList: [
        {
          numColor: '#559a27',
          roundColor: '#6EC236',
          barColor: '#D3F0DA',
          leftText: '外向 E',
          rightText: '内向 I'
        },
        {
          numColor: '#E88510',
          roundColor: '#FFCC00',
          barColor: '#F2DEA5',
          leftText: '直觉 N',
          rightText: '现实 S'
        },
        {
          numColor: '#A769E8',
          roundColor: '#AB65F4',
          barColor: '#D2C7F3',
          leftText: '思考 T',
          rightText: '情感 F'
        },
        {
          numColor: '#4186F1',
          roundColor: '#2C8DF6',
          barColor: '#CAE3F5',
          leftText: '评判 J',
          rightText: '随性 P'
        }
      ]
    };
  },

  onReady() {},

  mounted() {
    uni
      .createSelectorQuery()
      .in(this)
      .select('.personality-attributes')
      .boundingClientRect((rect) => {
        this.$emit('listenRect', rect);
      })
      .exec();
  },
  methods: {}
};
</script>

<style lang="scss" scoped>
.personality-attributes {
  position: relative;
  width: 100%;
  .title-img-box {
    display: flex;
    .title-img {
      height: 112rpx;
      width: 470rpx;
    }
  }
  .content-wrapper {
    margin: -14rpx 32rpx 0 32rpx;
    background: #fff;
    border-radius: 0rpx 20rpx 0rpx 0rpx;
    .content {
      padding: 53rpx 42rpx 42rpx 42rpx;
      background: linear-gradient(0deg, #ffffff 0%, #8de5ba 100%) no-repeat;
      border: 1px solid #ffffff;
      background-size: 100% 83rpx;
      border-radius: 0rpx 20rpx 0rpx 0rpx;
      .title-box {
        display: flex;
        align-items: center;
        position: relative;
        .black-line {
          width: 12rpx;
          height: 37rpx;
          background: #000000;
          position: absolute;
          left: -42rpx;
        }
        .title-en {
          font-family: Source Han Sans CN;
          font-weight: 600;
          font-size: 60rpx;
          color: #222222;
        }
      }
      .title-ch {
        font-family: Source Han Sans CN;
        font-weight: 600;
        font-size: 45rpx;
        color: #222222;
        margin-top: 8rpx;
      }
      .avatar-box {
        position: absolute;
        width: 258rpx;
        height: 234rpx;
        right: 36rpx;
        top: 60rpx;
        z-index: 9;
        background: url($img-base + 'career/careerAssessNewImg/01_avatar.png')
          no-repeat;
        background-size: 100% 100%;
        background-position: center;
        .avatar {
          width: 153rpx;
          height: 153rpx;
          padding: 36rpx 0 0 50rpx;
        }
      }
      .progress-container {
        margin-top: 50rpx;
      }
      .desc {
        margin-top: 16rpx;
        font-family: Source Han Sans CN;
        font-size: 30rpx;
        color: #888888;
        line-height: 48rpx;
      }
    }
  }
}
</style>
